package com.trimps.wifi.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.trimps.wifi.exception.LoginException;
import com.trimps.wifi.exception.SqlOperationsException;
import com.trimps.wifi.mapper.BlacklistMapper;
import com.trimps.wifi.mapper.UserMapper;
import com.trimps.wifi.pojo.BlacklistInfoData;
import com.trimps.wifi.pojo.User;
import com.trimps.wifi.service.BlacklistService;
import com.trimps.wifi.service.IUserService;

@Service("BlacklistService")
public class BlacklistServiceImpl implements BlacklistService {
	@Autowired
	private BlacklistMapper blacklistMapper;	


	@Override
	public List<BlacklistInfoData> getBlacklistByKeyword(String keywords, int currentPage, int rowPerPage) {
	    int start = 0;
        if (rowPerPage == 0) {
            rowPerPage = 10;
        }
        if (currentPage != 0) {
            start = (currentPage - 1) * rowPerPage;
        }
	    return blacklistMapper.getBlacklistByKeyword(keywords, start, rowPerPage);
	}
	
	@Override
	public BlacklistInfoData getBlacklistById(int id){
        return blacklistMapper.getBlacklistById(id);
    }

    @Override
    public int getBlacklistCountByKeyword(String keywords) {
        return blacklistMapper.getBlacklistCountByKeyword(keywords);
    }

    @Override
    public int delBlacklistById(int id) {
        return blacklistMapper.delBlacklistById(id);
    }

    @Override
    public int addBlacklist(BlacklistInfoData blacklistInfoData) {
        return blacklistMapper.addBlacklist(blacklistInfoData);
    }

    @Override
    public int updateBlacklist(BlacklistInfoData blacklistInfoData) {
        return blacklistMapper.updateBlacklist( blacklistInfoData);
    }
}
